#ifndef _DYNAARRLIB_H_
#define _DYNAARRLIB_H_

#define DEBUG 

typedef struct {
	unsigned int size;		/* now, the numbers of the array element */
	unsigned int length;	/* the max numbers of the array element that size can reached */
	void **items;			/* array pointer */
}cel_array_t;

//generic compare function
typedef int ( * cel_compare_fn_t ) ( void *, void * );
typedef void ( * cel_release_callback_fn_t ) ( void * );

/**************************API***********************/

#define cel_array_size( array ) (array->size) /* count the size of the specified cel array */
#define new_cel_array_default new_cel_array_opacity(16)
cel_array_t *new_cel_array_opacity(int opacity);
void free_cel_array(cel_array_t **array, cel_release_callback_fn_t relfunc);

void cel_array_add(cel_array_t *array, void *value);

void *cel_array_get(cel_array_t *array, unsigned int idx);
int cel_array_get_obj(cel_array_t *array, void *obj, cel_compare_fn_t cfunc);

void *cel_array_set(cel_array_t *array, unsigned int idx, void *value);
/* 下面两个尽量少使用 */
int cel_array_insert(cel_array_t *array, unsigned int idx, void *value);
void *cel_array_del(cel_array_t *array, unsigned int idx);

#endif //_DYNAARRLIB_H_
